#include <iostream>
#include <fstream>
#include <windows.h>
#include <ctime>

int main(int argc, char **argv)
{
	char buf[2000];
	char cmd[2048] = "mkdir ";
	struct tm *m_time;
	time_t t;
	t = time(NULL);
	m_time = localtime(&t);
	GetCurrentDirectoryA(2048, buf);
	strcat(cmd, buf);
	strcat(cmd, "\\_post");
	strcat(buf, "\\_post\\MyPost.md");
	std::cout << "Target:" << buf << std::endl;
	std::cout << "cmd:" << cmd << std::endl;
	std::ofstream out11(buf);
	if(! out11.is_open()){
		system(cmd);
		std::cout << "making direction" << std::endl;
		out11.open(buf);
		if (!out11.is_open()) {
			std::cout << "Failed" << std::endl;
		}else{
			out11 << "---\nlayout: post\ntitle : \"Welcome to Jekyll!\"\ndate : "
				<< 1900 + m_time->tm_year << "-" << 1 + m_time->tm_mon << "-" << m_time->tm_mday << "\ncategories : \n--- ";
			out11.close();
		}
	}else{
		out11 << "---\nlayout: post\ntitle : \"Welcome to Jekyll!\"\ndate : "
			<< 1900 + m_time->tm_year << "-" << 1 + m_time->tm_mon << "-" << m_time->tm_mday << "\ncategories : \n--- ";
		out11.close();
	}
	return 0;
}